package com.wentao.mall.entity

import com.fasterxml.jackson.databind.ObjectMapper
import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.info.Info
import org.apache.catalina.connector.Connector
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class BaseConfig {
    @Bean
    fun customOpenAPI(): OpenAPI {
        return OpenAPI().info(Info().title("我的API").version("0.0.1").description("描述"))
    }

    @Bean
    fun mapper(): ObjectMapper {
        return ObjectMapper()
    }

    @Bean
    fun webServerFactory(): TomcatServletWebServerFactory? {
        val factory = TomcatServletWebServerFactory()
        factory.addConnectorCustomizers(TomcatConnectorCustomizer { connector: Connector ->
            connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}")
            connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}")
        })
        return factory
    }


}



